<template>
    <div class="outContent loginFace">
        <div class="loginBox">
            <div class="formRow">
                <input class="input_user" type="text" v-model="userName" placeholder="帐号"/>
            </div>
            <div class="formRow">
                <input class="input_password" type="password" v-model="password" placeholder="密码"/>
            </div>
            <div class="formRow">
                <button class="btn_login" @click="handleSubmit">登 陆</button>
            </div>
            <div class="formRow">
                <a href="#" class="forget">忘记密码</a>
            </div>

        </div>
    </div>

</template>

<script>
import { mapActions } from 'vuex'
import { getToken } from '../../libs/util'
export default {
  name: 'login',

  data () {
    return {
      userName: '',
      password: ''

    }
  },

  methods: {
    ...mapActions([
      'handleLogin',
      'getUserInfo'
    ]),
    handleSubmit () {
      let para = { userName: this.userName, password: this.password }
      this.handleLogin(para).then(res => {
        // this.getUserInfo().then(res => {
        // })
        let token = getToken()
        if (!!token && token != 'undefined'){
          this.$router.push('/')
        }else{
          this.$router.push('/login')
        }

      })
    }
  }

}
</script>

<style scoped>

</style>
